package com.example.cofeed.adapter;

import android.text.TextUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.cofeed.R;
import com.example.cofeed.entity.Catalogs;

/**
 * Created by mqwang on 2017/9/18.
 */

public class AttentionBreedAdapter extends BaseQuickAdapter<Catalogs, BaseViewHolder> {
    public AttentionBreedAdapter() {
        super(R.layout.item_attention_breed_list);
    }

    @Override
    protected void convert(BaseViewHolder helper, Catalogs item) {
        if (!TextUtils.isEmpty(item.catalogid)){
            if (item.isSelect){
                helper.setBackgroundRes(R.id.name_tv, R.drawable.bg_btn);
                helper.setTextColor(R.id.name_tv, mContext.getResources().getColor(R.color.colorWhite));
            }
            else{
                helper.setBackgroundRes(R.id.name_tv, R.drawable.bg_round);
                helper.setTextColor(R.id.name_tv, mContext.getResources().getColor(R.color.mainThemeColor));
            }
        }

        helper.setText(R.id.name_tv, item.title);

    }

    public void setSelect(Catalogs select){
//        for (Catalogs breed: mData){
//            breed.isSelect = false;
//        }
        select.isSelect = !select.isSelect;
        notifyDataSetChanged();

    }

    public void setSingleSelect(Catalogs select){
        for (Catalogs breed: mData){
            breed.isSelect = false;
        }
        select.isSelect = !select.isSelect;
        notifyDataSetChanged();

    }
}
